package com.houweishi.module.clocktype.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.houweishi.common.annotation.Log;
import com.houweishi.common.core.controller.BaseController;
import com.houweishi.common.core.domain.AjaxResult;
import com.houweishi.common.enums.BusinessType;
import com.houweishi.module.clocktype.domain.BizClockingType;
import com.houweishi.module.clocktype.service.IBizClockingTypeService;
import com.houweishi.common.utils.poi.ExcelUtil;
import com.houweishi.common.core.page.TableDataInfo;

/**
 * 打卡类型
Controller
 * 
 * @author houweishi
 * @date 2023-03-01
 */
@RestController
@RequestMapping("/module/clocktype")
public class BizClockingTypeController extends BaseController
{
    @Autowired
    private IBizClockingTypeService bizClockingTypeService;

    /**
     * 查询打卡类型
列表
     */
    @PreAuthorize("@ss.hasPermi('module:clocktype:list')")
    @GetMapping("/list")
    public TableDataInfo list(BizClockingType bizClockingType)
    {
        startPage();
        List<BizClockingType> list = bizClockingTypeService.selectBizClockingTypeList(bizClockingType);
        return getDataTable(list);
    }

    /**
     * 导出打卡类型列表
     */
    @PreAuthorize("@ss.hasPermi('module:clocktype:export')")
    @Log(title = "打卡类型 ", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BizClockingType bizClockingType)
    {
        List<BizClockingType> list = bizClockingTypeService.selectBizClockingTypeList(bizClockingType);
        ExcelUtil<BizClockingType> util = new ExcelUtil<BizClockingType>(BizClockingType.class);
        util.exportExcel(response, list, "打卡类型 数据");
    }

    /**
     * 获取打卡类型
详细信息
     */
    @PreAuthorize("@ss.hasPermi('module:clocktype:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(bizClockingTypeService.selectBizClockingTypeById(id));
    }

    /**
     * 新增打卡类型

     */
    @PreAuthorize("@ss.hasPermi('module:clocktype:add')")
    @Log(title = "打卡类型 ", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BizClockingType bizClockingType)
    {
        return toAjax(bizClockingTypeService.insertBizClockingType(bizClockingType));
    }

    /**
     * 修改打卡类型

     */
    @PreAuthorize("@ss.hasPermi('module:clocktype:edit')")
    @Log(title = "打卡类型 ", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BizClockingType bizClockingType)
    {
        return toAjax(bizClockingTypeService.updateBizClockingType(bizClockingType));
    }

    /**
     * 删除打卡类型

     */
    @PreAuthorize("@ss.hasPermi('module:clocktype:remove')")
    @Log(title = "打卡类型 ", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(bizClockingTypeService.deleteBizClockingTypeByIds(ids));
    }
}
